package com.maya.utilities;


import com.maya.R;
import com.maya.screens.Constants;

import android.content.Context;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

public class Utilities 
{	
	public void showToast(Context con, int messageID, int milliseconds, int imageType)
	{
		Toast dialog = Toast.makeText(
				con,
				messageID,
				Toast.LENGTH_LONG);

		dialog.setGravity(Gravity.CENTER, 0, 0);
		LinearLayout dialogView = (LinearLayout) dialog.getView();
		ImageView image = new ImageView(con);
		
		if(imageType == Constants.ERROR_ICON_ID)
		{
			image.setImageResource(R.drawable.error);
		}
		else if(imageType == Constants.INFO_ICON_ID)
		{
			image.setImageResource(R.drawable.info);
		}
		else if(imageType == Constants.WARN_ICON_ID)
		{
			image.setImageResource(R.drawable.warning);
		}
		else if(imageType == Constants.QUES_ICON_ID)
		{
			image.setImageResource(R.drawable.question);
		}
		else if(imageType == Constants.STAR_ICON_ID)
		{
			image.setImageResource(R.drawable.star);
		}
		else if(imageType == Constants.MAYA_ICON_ID)
		{
			image.setImageResource(R.drawable.maya);
		}
		else if(imageType == Constants.SADNESS_ICON_ID)
		{
			image.setImageResource(R.drawable.sadness);
		}	
		else
		{
			
		}
		dialogView.addView(image, 0);
		dialog.setDuration(milliseconds);
		dialog.show();
	}
	
	public MediaPlayer playSound(MediaPlayer media, Context con, int resourceID)
	{
		media = MediaPlayer.create(con, resourceID);   
		media.start();
		media.setOnCompletionListener(new OnCompletionListener() {
			public void onCompletion(MediaPlayer mp) {
				mp.release();
				}
			});
		return media;
	}

}
